import request from '../utils/request';
import { API } from '../utils/config';

/**
 * 获取分类列表
 * @returns 返回分类列表数据
 */
export const getCategoryList = () => {
  return request({
    url: `${API.CLASSES}/Category`,
    method: 'GET',
    params: {
      order: 'sort',
      limit: 1000, // 增加limit参数，确保获取所有数据
      count: 1, // 返回总数
    }
  });
};

/**
 * 创建分类
 * @param data 分类数据
 */
export const createCategory = (data: any) => {
  return request({
    url: `${API.CLASSES}/Category`,
    method: 'POST',
    data
  });
};

/**
 * 更新分类
 * @param id 分类ID
 * @param data 分类数据
 */
export const updateCategory = (id: string, data: any) => {
  return request({
    url: `${API.CLASSES}/Category/${id}`,
    method: 'PUT',
    data
  });
};

/**
 * 删除分类
 * @param id 分类ID
 */
export const deleteCategory = (id: string) => {
  return request({
    url: `${API.CLASSES}/Category/${id}`,
    method: 'DELETE'
  });
};

/**
 * 获取分类详情
 * @param id 分类ID
 */
export const getCategoryDetail = (id: string) => {
  return request({
    url: `${API.CLASSES}/Category/${id}`,
    method: 'GET'
  });
}; 